// 路由-相关模块
import Vue from 'vue'
import VueRouter from 'vue-router'
// @表示src的绝对路径
import Layout from '@/views/Layout'
import Home from '@/views/Home'
import Search from '@/views/Search'
import Play from '@/views/Play'
// 让Vue使用VueRouter，注册一些全局组件或者挂在原型上一些方法
Vue.use(VueRouter)
// 路由匹配规则
const routes = [{
  path: '/',
  redirect: '/layout',
},
{
  path: '/layout',
  component: Layout,
  redirect: '/layout/home',
  children: [
    {
      path: 'home',
      component: Home,
      //表示元信息
      meta: {
        title:'首页'
      }
    },
    {
      path: 'search',
      component: Search,
      meta: {
        title:'搜索'
      }
    }
  ]
  },
  {
    path: '/play',
    component: Play,
},
]
// 创建路由实例对象
const router = new VueRouter({
  routes
})
// 对外暴露路由实例对象
export default router